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.66]) by mx.groups.io with SMTP id smtpd.web10.6547.1572448944380226179 for ; Wed, 30 Oct 2019 08:22:24 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@outlook.com header.s=selector1 header.b=A0FKhBLv; spf=pass (domain: outlook.com, ip: 40.92.69.66, mailfrom: minnowware@outlook.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OHg0e2262MRWxguolMAyzItfikqi9D6iiYvCWCcWfb/5nHM1mFEHjOiaB3ZrznUOj//vfQke8FX7cdCn65F8WoZuBVbt3yWqxj6TnJbcMvly3moJXu+pfRlyojAZI27R+x+DJPbsR9/rtRD6lgvA+ByMfDumrp3yQuWR+mfIn+NEmNpUrtH2pMS9x3mbccAhgnn+MzeZjfNbbsywsIh+z4Y1SrAmbgfcJo0RjP3cooC+N9PMrPu5Mii9yhx4mzX57X2oY2YttTE+LzAJRT/i8z3QNvUh6N/RBwitB9nCl+YGQycRaJPYJYcTN0+nWG5oS9CeDsFF3DOxnFFq6ZnsCg== 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=C6NF9iWsJ4GAANfautmaDsk93ltkinY+eOw6GMM8m08=; b=j2bBpApscc/LBviC8C/RGpMhFn3X+4kh4QJeMGFHc1FziCCZiTWaVbNJZIQf9TICx42eEeBt0MoE0CvGbBB6fi+ylBMAjQ5zEav7eyzpJKrpUO4bbBc7hT+w/julhFJ4SWdCW76EVs5aAOO3eiz6DXnjIfw8CUEKpjazuknoR3qZ4TwUdzZcKEFumvnt7ZiCS2XOENuTQ36E4FJov8RpkdKGCD4DC++L4yuhX5qCeHCjMRXtZuDjY5DJZvKxdzvsbupNEcju43G01zcs39OTYlFv6aVL58J7DKPmVUM2z+k5R5z5vWKjH4Y7LXb13K5A1x+F6iliBy1cjLxcIGNTzg== 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=C6NF9iWsJ4GAANfautmaDsk93ltkinY+eOw6GMM8m08=; b=A0FKhBLvMTzaq1X9OgHDEPYHBPMf2K+CjE34kKpzV13ZMvj6cV1t+AILLJHz90hCOarpRw7a5UdkmPiIncpeROWyht8c+lbSnyEJ7/1U37tJwRmz5wKiCdq7W3Vw5rYIgE0LYFRbo+WDAeHKhvjA0JxnqESMHStiGW0UA9JppV5TcF3xdnKq4DeoSCNqQTM2s7ymnQgp3gO/R1jb/uk3gNpGodNaM21PmBh4MO+9a27aP7zvcloYyC6ATwNqxmrN+jzGu4KGDDr5erKdjr41pQ4DnLlLNIA3moAM5/li7H0zUJUiIVX39mVY6qKhMLf9Bj5Yv2qxcHt6tl1S5EQO0Q== Received: from VE1EUR02FT025.eop-EUR02.prod.protection.outlook.com (10.152.12.53) by VE1EUR02HT222.eop-EUR02.prod.protection.outlook.com (10.152.13.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2387.20; Wed, 30 Oct 2019 15:22:21 +0000 Received: from DB6PR04MB3047.eurprd04.prod.outlook.com (10.152.12.57) by VE1EUR02FT025.mail.protection.outlook.com (10.152.12.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2387.20 via Frontend Transport; Wed, 30 Oct 2019 15:22:21 +0000 Received: from DB6PR04MB3047.eurprd04.prod.outlook.com ([fe80::39c8:790d:aece:25f4]) by DB6PR04MB3047.eurprd04.prod.outlook.com ([fe80::39c8:790d:aece:25f4%5]) with mapi id 15.20.2387.027; Wed, 30 Oct 2019 15:22:21 +0000 From: "Minnow Ware" To: "devel@edk2.groups.io" , "liming.gao@intel.com" , "KILIAN_KEGEL@OUTLOOK.COM" CC: "Richardson, Brian" , "Kinney, Michael D" , "Ni, Ray" Subject: Re: [edk2-devel] [edk2] [EmulatorPkg] using __debugbreak() Thread-Topic: [edk2-devel] [edk2] [EmulatorPkg] using __debugbreak() Thread-Index: AQHVjY/UBttlBtLHMk6PSdJquNv9f6dyrA4AgAA+RoCAAGDZgIAAARRo Date: Wed, 30 Oct 2019 15:22:21 +0000 Message-ID: References: <2d5ec4d308504c87b7b1390c1e2f1495@zhaoxin.com>,<4A89E2EF3DFEDB4C8BFDE51014F606A14E5325C1@SHSMSX104.ccr.corp.intel.com> ,<4A89E2EF3DFEDB4C8BFDE51014F606A14E534825@SHSMSX104.ccr.corp.intel.com> ,<4A89E2EF3DFEDB4C8BFDE51014F606A14E534D71@SHSMSX104.ccr.corp.intel.com> In-Reply-To: <4A89E2EF3DFEDB4C8BFDE51014F606A14E534D71@SHSMSX104.ccr.corp.intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:CF37C1B6EB8A8A6C04EA39C98F173A726E190FF96AEC6086F0B2716FD3EC4169;UpperCasedChecksum:CAC69FD822FAF81DF7CF86376E021A63B4733ED430F51DDF93633D4337278553;SizeAsReceived:7471;Count:44 x-tmn: [lBadW0X2jgV0VpLKUK6vZuPIBostUEjl] x-ms-publictraffictype: Email x-incomingheadercount: 44 x-eopattributedmessage: 0 x-ms-exchange-slblob-mailprops: =?Windows-1252?Q?inBjZRGSCZn9RGmCPk6ekRJurRGm5MieApf7rCtHBHbhfvU9MZWdjff9?= =?Windows-1252?Q?yW6P+75o1hrzwguKDIumOGAazIvTGiOq8ctRjWfwV+J58K3LWAc2Al1U?= =?Windows-1252?Q?SCHpq1+eCChd4wMPugGjAN3X86AJ28rRvB6JPXUmIfjgDOU1iyO3FpRt?= =?Windows-1252?Q?DoowBVKHc7sBx0a/qQXJn1iZ1t82y9Vqq3gWKMvplNRh0zITh7V+WOlH?= =?Windows-1252?Q?LCOwqCbuLTDuAD1a7rXNCjX504PS9UEKDXAx+jUdNWZc4xIdxc0dJKLy?= =?Windows-1252?Q?3msflyPr30d3Y7O8axPkXzUv+xCjcZ4Ked25jYtRfhizrslu93HqZL7V?= =?Windows-1252?Q?7AZtEQXVgL2DQ/Pd9tE5tuiidGWTtEdsfzbDYMi1pInhj7U3wZSpBLBd?= =?Windows-1252?Q?MdP8dl41d5XXOcBF+ocSh7NAi6F5obp2Qhv0HCIEfMHEKWSbO/9vwL0G?= =?Windows-1252?Q?SGz7k2h81MIZ0sRRMSwucedL7MjkHoYYerhrdTl6AhwNg/puS9yRdy8x?= =?Windows-1252?Q?SgFFg6JewoLKLfvQNtf8R5XJobdgN13vdqTB+6oB61bC72ENj4drQ7NT?= =?Windows-1252?Q?00rmBNPJI1eq3518OE1N0WGOvkB2X13RQ3ciOePF4Yi45iTB9VWh4uEM?= =?Windows-1252?Q?qobLmeKBMIVc2RK7kQSPmzJaMN/+VuZEFZhB09gvNRqh0TY7eaqU16W9?= =?Windows-1252?Q?esULvmtrB+hlrJ2C2yydwxIGCjCGgnGin9VtYOBkFvpp9ZAPG2yiGHql?= =?Windows-1252?Q?YvGyhrEPCNIGGhaAbWu0YH0vCha+d443gCjCRAcGaan4z4Q24j6E7zrv?= =?Windows-1252?Q?KxQckG8n3rk4yf/PxdOfdmb9uLrWgcew2xSUxaP8ZHhIJ6/J5CdC3eHf?= =?Windows-1252?Q?AKXfCxWwINeFpehsuR2kXBH3fNezrSurD5x/UN9zsFnuyq0sF/u743fA?= =?Windows-1252?Q?J53uRTjhRawB9OKuUiCpoEw9TOJ4U71+bmrnjTjVsr6PSiUS5vzqBFXE?= =?Windows-1252?Q?S2+g9ICduhV1WBmKW+yfSyFoOHUGyw=3D=3D?= x-ms-traffictypediagnostic: VE1EUR02HT222: x-ms-exchange-purlcount: 5 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: VMpLLois5FVdQAWgOykLxjibQHx9SJf8HcUXKNPMNDWeqVvz2syhZvU4fD/NAZcR9b8MZOcEPQK5FJoIC6wCu5lfZOSg8g2Jplq5EXdiEaVX9ED3b3BbfyaXI5n72qOPTpcBHvU7xZ6viAHqFMlDmOfzJf0oE3qHam/ghWle4xrIOpVhXa4hSAL4tfdv+0g799Wsah565PC9CVRTeOccLL6hIZCO8wDIP2P73x+v3j0= 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: 86825781-d36f-4c03-4da4-08d75d4cf5cb X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Oct 2019 15:22:21.8304 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1EUR02HT222 Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_DB6PR04MB3047F06DF317BB40984A3CD8C1600DB6PR04MB3047eurp_" --_000_DB6PR04MB3047F06DF317BB40984A3CD8C1600DB6PR04MB3047eurp_ Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable Hi Liming, 1. when you invoke WINHOST.EXE /debug, it waits for developer input 2. otherwise default behavior A PCD is needless. Regards, Kilian ________________________________ From: devel@edk2.groups.io on behalf of Liming Gao = Sent: Wednesday, October 30, 2019 4:03:13 PM To: devel@edk2.groups.io ; KILIAN_KEGEL@OUTLOOK.COM = Cc: Richardson, Brian ; Kinney, Michael D ; Ni, Ray Subject: Re: [edk2-devel] [edk2] [EmulatorPkg] using __debugbreak() Kilian: I think this idea is good. It can be enabled when the developer wants to = do the source level debug. So, one PCD may be introduced to control the log= ic. By default, there is no change. When PCD is enabled, WinHost will wait = for the developer input. Can you submit BZ for this request, and prepare the patch for the change? Thanks Liming From: devel@edk2.groups.io On Behalf Of Kilian Kege= l Sent: Wednesday, October 30, 2019 5:17 PM To: Gao, Liming ; devel@edk2.groups.io Cc: Richardson, Brian ; Kinney, Michael D Subject: Re: [edk2-devel] [edk2] [EmulatorPkg] using __debugbreak() Hi Liming, CpuBreakPoint() is the same as __debugbreak() on Microsoft Compiler and ge= nerates INT 3 DebugTrap. Yes, that procedure has worked in the past and I have used it in the same = way as you do. But with newer Windows versions, Windows just terminates the =93exceptiona= l=94 process that emits INT 3 or any other violation trap and does not offer to debug the process = = =96 surly for security reasons=85 For debugging purpose on newer Windows 10 versions I always insert the cod= e snippet below. It gives the developer the chance to connect VS to the process to be debug= ged, while waiting on keyboard input. (ALT-CTRL-P attach to process) After that, with the debuggee is connected to VS _before_ the debug trap a= ppears. VS is now available for debugging the process with full source code. The EmulatorPkg (and Nt32Pkg) was the most helpful tool to understand and = debug UEFI internals for me. EmulatorPkg should also usable and helpful for other devolpers. Can you please insert the code snippet into main() from WinHost.c? Thanks, Kilian From: Gao, Liming Sent: Wednesday, October 30, 2019 06:33 AM To: devel@edk2.groups.io; KILIAN_KEGEL@OUTLOO= K.COM Cc: Richardson, Brian; Kinney, Michael = D Subject: RE: [edk2-devel] [edk2] [EmulatorPkg] using __debugbreak() Kilian: I normally modify the source code and insert CpuBreakpoint() function. = That will trig VS debugger for the source code. Thanks Liming From: devel@edk2.groups.io [mailto:devel@edk2= .groups.io] On Behalf Of Kilian Kegel Sent: Monday, October 28, 2019 9:01 PM To: Gao, Liming > Cc: devel@edk2.groups.io; Richardson, Brian <= brian.richardson@intel.com>; Kinney, Mic= hael 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 debu= g 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 d= ebugger 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 beg= inning 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"); SecPrint("\t1. start Visual Studio\n"); SecPrint("\t2. DEBUG->ATTACH TO PROCESS (CTRL + AL= T + P) --> WinHost.exe\n"); SecPrint("\t3. Break All (CTRL + ALT + Break) -->= WinHost.exe\n"); SecPrint("\t4. SET A SOFTWARE BREAKPOINT (F9) in l= ine 445\n"); SecPrint("\t5. and press ENTER in this command box= \n"); SecPrint("\t6. go back to Visual Studio an RUN/SIN= GLE STEP the application\n"); SecPrint("\t7. otherwise press enter to continue..= .\n"); getchar(); // // 1. SET A SOFTWARE BREAKPOINT TO THE NEXT LINE o= f code below -->> SecPrint(""); // 2. switch to the command box and press ENTER // 3. start single stepping the entire boot/emulat= ion process, good luck... // SecPrint("");//now you can single step the entire = boot/emulation process, good luck... } } } } --_000_DB6PR04MB3047F06DF317BB40984A3CD8C1600DB6PR04MB3047eurp_ Content-Type: text/html; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable

Hi Liming,

 

  1. when you invoke WINHOST.EXE /debug, it waits for develope= r input
  2. otherwise default behavior

 

A PCD is needless.

 

Regards,

Kilian

 


From: devel@edk2.groups.io= <devel@edk2.groups.io> on behalf of Liming Gao <liming.gao@intel.= com>
Sent: Wednesday, October 30, 2019 4:03:13 PM
To: devel@edk2.groups.io <devel@edk2.groups.io>; KILIAN_KEGEL= @OUTLOOK.COM <KILIAN_KEGEL@OUTLOOK.COM>
Cc: Richardson, Brian <brian.richardson@intel.com>; Kinney, M= ichael D <michael.d.kinney@intel.com>; Ni, Ray <ray.ni@intel.com&g= t;
Subject: Re: [edk2-devel] [edk2] [EmulatorPkg] using __debugbreak()=
 

K= ilian:

&= nbsp;I think this idea is good. It can be enabled when the developer wants = to do the source level debug. So, one PCD may be introduced to control the = logic. By default, there is no change. When PCD is enabled, WinHost will wait for the developer input.

&= nbsp;

C= an you submit BZ for this request, and prepare the patch for the change?

&= nbsp;

T= hanks

L= iming

From: devel@edk2.groups.io <= ;devel@edk2.groups.io> On Behalf Of Kilian Kegel
Sent: Wednesday, October 30, 2019 5:17 PM
To: Gao, Liming <liming.gao@intel.com>; devel@edk2.groups.io<= br> Cc: Richardson, Brian <brian.richardson@intel.com>; Kinney, M= ichael D <michael.d.kinney@intel.com>
Subject: Re: [edk2-devel] [edk2] [EmulatorPkg] using __debugbreak()=

 

Hi Liming,

 

CpuBreakPoint() is the same = as __debugbreak() on Microsoft Compiler and generates INT 3 DebugTrap.

 

Yes, that procedure has work= ed in the past and I have used it in the same way as you do.

 

But with newer Windows versi= ons, Windows just terminates the =93exceptional=94 process that emits

INT 3 or any other violation= trap and does not offer to debug the process =96 surly for security reason= s=85

 

For debugging purpose on new= er Windows 10 versions I always insert the code snippet  below.=

 

It gives the developer the c= hance to connect VS to the process to be debugged, while waiting on keyboar= d input.

(ALT-CTRL-P attach to proces= s)

 

After that, with the debugge= e is connected to VS _before_ the debug trap appears. VS is now

available for debugging the = process with full source code.

 

The EmulatorPkg (and Nt32Pkg= ) was the most helpful tool to understand and debug UEFI internals for me.<= /span>

 

EmulatorPkg should also usab= le and helpful for other devolpers.

Can you please insert the co= de snippet into main() from WinHost.c?

 

Thanks,

Kilian

 

 

From: Gao, Liming
Sent: Wednesday, October 30, 2019 06:33 AM
To: devel@edk2.groups.io; KILIAN_KEGEL@OUTLOOK.COM
Cc: Richardson, Brian= ; Kinney, Michael D
Subject: RE: [edk2-devel] [edk2] [EmulatorPkg] using __debugbreak()=

 

Kili= an:

&nbs= p;  I normally modify the source code and insert CpuBreakpoint() funct= ion. That will trig VS debugger for the source code.

&nbs= p;

Than= ks

Limi= ng

From: devel@edk2.groups.io [mailto:d= evel@edk2.groups.io] On Behalf Of Kilian Kegel
Sent: Monday, October 28, 2019 9:01 PM
To: Gao, Liming <liming.= gao@intel.com>
Cc: devel@edk2.groups.io; Richardson, Brian <bria= n.richardson@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Subject: [edk2-devel] [edk2] [EmulatorPkg] using __debugbreak()

 

Hi Liming,

 

If have observed in newer Wi= ndows 10 versions, when using __debugbreak()in any

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

So in WinHost.exe too.

 

That=92s why I usually inser= t 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 p= rocess for debugging.

 

Do you have a better solutio= n without modifying the source code?

 

Thanks,

Kilian

    if(1){=

    &= nbsp;   int i;

 

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

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

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

 

     =    if(Argc > 1){

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

    &= nbsp;           if(0 =3D= =3D strcmp(&q= uot;/debug", Argv[i])){

    &= nbsp;           &nbs= p;       //SecPrint("IF YOU WANT TO DEBU= G from the very beginning of the EMULATION:\n\t1. start the TASKMGR\n\t2. c= onnect WinHost.exe to the debugger\n\t3. and press ENTER in this command bo= x\nOR\n");

    &= nbsp;           &nbs= p;       SecPrint("\t1. start Visual Stu= dio\n");

    &= nbsp;           &nbs= p;       SecPrint("\t2. DEBUG->ATTACH= TO PROCESS (CTRL + ALT + P) --> WinHost.exe\n");

    &= nbsp;           &nbs= p;       SecPrint("\t3. Break All  = (CTRL + ALT + Break) --> WinHost.exe\n");

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

    &= nbsp;           &nbs= p;       SecPrint("\t5. and press ENTER = in this command box\n");

    &= nbsp;           &nbs= p;       SecPrint("\t6. go back to Visua= l Studio an RUN/SINGLE STEP the application\n");

    &= nbsp;           &nbs= p;       SecPrint("\t7. otherwise press = enter to continue...\n");

    &= nbsp;           &nbs= p;       getchar();

    &= nbsp;           &nbs= p;       //

    &= nbsp;           &nbs= p;       // 1. SET A SOFTWARE BREAKPOINT TO T= HE NEXT LINE of code below -->> SecPrint("");

    &= nbsp;           &nbs= p;       // 2. switch to the command box and = press ENTER

    &= nbsp;           &nbs= p;       // 3. start single stepping the enti= re boot/emulation process, good luck...

    &= nbsp;           &nbs= p;       //

    &= nbsp;           &nbs= p;       SecPrint("");//now you can= single step the entire boot/emulation process, good luck...

    &= nbsp;           &nbs= p;  }

    &= nbsp;       }

    &= nbsp;   }

    }

 

--_000_DB6PR04MB3047F06DF317BB40984A3CD8C1600DB6PR04MB3047eurp_--