From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR02-AM5-obe.outbound.protection.outlook.com (EUR02-AM5-obe.outbound.protection.outlook.com [40.92.67.54]) by mx.groups.io with SMTP id smtpd.web09.956.1573811773780295910 for ; Fri, 15 Nov 2019 01:56:14 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@outlook.com header.s=selector1 header.b=BNVU2XKy; spf=pass (domain: outlook.com, ip: 40.92.67.54, mailfrom: kilian_kegel@outlook.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jf3oOCK4WZxG/BBzwM8lePgr8va01LZv6BrZjA8rOS0yo5kiP8oUXecaWF38tkDOi7hv+/OOlEGhr7t6+VYVRtcXgee2o5zu4MWDSOqiQH7O68qWkv9mEqLf9fYSUajoh7zNGAHJbyMbBrJfLAJAUBQZDepSbJdEOZpM3I4zkxpLsCoiVwDPtmBlwZ4l66EzvAjrWLPe0CdkaqqGgimvgZSqnO4aBKmVduyMrizIxObq7PCRu3EoxqYu8l+0LsunSd+ma+gnlc92584q7s/+iW7zaacVpCz2txkvUdFmELdVuNsGj6KTeDVM0sge5AnxHEljQpd8OTRV8jegRWD9JQ== 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=bdu4aEYscSPR5jHYmKoCVRpacVdO6bczylKZD4pdyVk=; b=Gy4VnkvL7tyAB3tUUiIvUIkHyjcov+73TLx/j6p3GSaQvDwzj/dUD+zNKsHYGAbO4I4LkPt3IXOhfzd6xZ2eqvXtNxBxM4qeomcQ90HWcBnvhbvg++y8tw4BUBszDsd4N4QmZf+KxAzds7ts+Ql49Tx5N6uEi4knTcleYvEsk/tiWGRlDiJY4t7oYtb0PbqyNZRuOBaf7bS9J7Fh+vR5n/mCaO2rRakrgALzk5ZEsK8m3L/vFjvFfzoLXUZsiDyxryGu5DdD/+UX/YPftiwifo3nOz3e71HB5vdLGEMbzox1GKwgWivKFP70NEvMilE8Lae2/lWCqQRkgTrV3WNLuA== 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=bdu4aEYscSPR5jHYmKoCVRpacVdO6bczylKZD4pdyVk=; b=BNVU2XKyYl0wP6VVzuaah25i/YTlnkv/xrJBNUmbijn/LohMW+rmJD2x+7D2nW/zNgwJUVW6a7ICXWIcd0eHa1KPUVx3jgCVj9MGTLBbnknQVcM/zCY9lRqSKIXCoMuqT94nZaR0WJaoZ3RIoEC7mTZnvSX+rcyIhIq6q4P9srjGrXItVSXHrV2xb0Tmp5V17NoEx/7o3PRr7ekyqUD0xJG1SoBhgz+0dd3CCyKZXxQL1Yydf2x5JKX1e8PQzK76c3jk5aSczaFJO+dga8nUzKOqnBD7PmODr+BnWzAq5k3hBZ9IrDFGUXKOOli4awLNdKAYhduu+v5/P74gK+Acvw== Received: from VE1EUR02FT047.eop-EUR02.prod.protection.outlook.com (10.152.12.52) by VE1EUR02HT044.eop-EUR02.prod.protection.outlook.com (10.152.13.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2451.23; Fri, 15 Nov 2019 09:56:10 +0000 Received: from VI1PR0502MB3968.eurprd05.prod.outlook.com (10.152.12.57) by VE1EUR02FT047.mail.protection.outlook.com (10.152.13.237) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2451.23 via Frontend Transport; Fri, 15 Nov 2019 09:56:10 +0000 Received: from VI1PR0502MB3968.eurprd05.prod.outlook.com ([fe80::4408:c7c7:aaa3:2a91]) by VI1PR0502MB3968.eurprd05.prod.outlook.com ([fe80::4408:c7c7:aaa3:2a91%7]) with mapi id 15.20.2451.027; Fri, 15 Nov 2019 09:56:10 +0000 From: "Kilian Kegel" To: "Ni, Ray" , "devel@edk2.groups.io" , "Gao, Liming" CC: "Richardson, Brian" , "Kinney, Michael D" Subject: Re: [edk2-devel] [[PATCH 1/1]] EmulatorPkg using CpuBreakPoint Thread-Topic: [edk2-devel] [[PATCH 1/1]] EmulatorPkg using CpuBreakPoint Thread-Index: AQHVk/+J8z3CQarrTkqSuX+dN7iWMaeIVTyAgAAWngCAAb3M1YAAH9UAgAHDfQk= Date: Fri, 15 Nov 2019 09:56:10 +0000 Message-ID: References: <2d5ec4d308504c87b7b1390c1e2f1495@zhaoxin.com>,<4A89E2EF3DFEDB4C8BFDE51014F606A14E5325C1@SHSMSX104.ccr.corp.intel.com>, <4A89E2EF3DFEDB4C8BFDE51014F606A14E53EAA0@SHSMSX104.ccr.corp.intel.com>,<734D49CCEBEEF84792F5B80ED585239D5C35B652@SHSMSX104.ccr.corp.intel.com> ,<734D49CCEBEEF84792F5B80ED585239D5C35E389@SHSMSX104.ccr.corp.intel.com> In-Reply-To: <734D49CCEBEEF84792F5B80ED585239D5C35E389@SHSMSX104.ccr.corp.intel.com> Accept-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:7E18B1FE417959C6F9FCB9DAAB60F296751C385AC0B8F92BA17F5BCB8145C94E;UpperCasedChecksum:35A55004D81B3D22F2B0653A393838CAA8F83A57C482854BD22699E6E8B946A1;SizeAsReceived:7681;Count:45 x-tmn: [7pDwDVnSqw2+S4gPyHg9fJYy+CkLeHpa] x-ms-publictraffictype: Email x-incomingheadercount: 45 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: c4acfe43-0eb9-4630-ac63-08d769b20b0a x-ms-traffictypediagnostic: VE1EUR02HT044: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: u1o7zN/hFBdbQiux8nm7rWCXInsXTlFrAh89SWAM/klKMIEpvu5lC1QQZefr1vH5iT2U0cnuc4lCwhYn5jsE/dsYaz0k/LzNZuQ1lYvOWcg8kcCbfmVaiZ+q0gXFer2gn8DIjE9g9Ooqw7Oq+xRgp3cVSAsJvho/89XnOGTU1AasNKmolzIr0QwyJA2VdPHm 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: c4acfe43-0eb9-4630-ac63-08d769b20b0a X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Nov 2019 09:56:10.5169 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1EUR02HT044 X-Groupsio-MsgNum: 50724 Content-Language: en-US Content-Type: multipart/related; boundary="_005_VI1PR0502MB396822D564BDF2ED5A713FC2EB700VI1PR0502MB3968_"; type="multipart/alternative" --_005_VI1PR0502MB396822D564BDF2ED5A713FC2EB700VI1PR0502MB3968_ Content-Type: multipart/alternative; boundary="_000_VI1PR0502MB396822D564BDF2ED5A713FC2EB700VI1PR0502MB3968_" --_000_VI1PR0502MB396822D564BDF2ED5A713FC2EB700VI1PR0502MB3968_ Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable Ray, thank you for your patience. Kilian diff --git a/EmulatorPkg/Win/Host/WinHost.c b/EmulatorPkg/Win/Host/WinHost= .c index 62a89f7617..b47a1fa8dd 100644 --- a/EmulatorPkg/Win/Host/WinHost.c +++ b/EmulatorPkg/Win/Host/WinHost.c @@ -394,6 +394,7 @@ Returns: UINTN ProcessAffinityMask; UINTN SystemAffinityMask; INT32 LowBit; + INT32 index; // // Enable the privilege so that RTC driver can successfully run SetTime= () @@ -410,6 +411,24 @@ Returns: SecPrint ("\n\rEDK II WIN Host Emulation Environment from http://www.ti= anocore.org/edk2/\n\r"); + SecPrint ("############################################################= ##########################################\n"); + SecPrint ("add \"/debug\" command line switch, to connect to the debugg= er at the very beginning of POST emulation\n"); + SecPrint ("############################################################= ##########################################\n"); + for (index =3D 1; index < Argc; index++) { + if (0 =3D=3D strcmp("/debug", Argv[index])) { + SecPrint("\t1. start your debug engine\n"); + SecPrint("\t2. attach to process WinHost.exe\n"); + SecPrint("\t4. set software breakpoints as needed in your debug s= ession\n"); + SecPrint("\t5. and press ENTER in the WinHost command box\n"); + SecPrint("\t6. go back to the debug engine and RUN/SINGLE STEP th= e application\n"); + SecPrint("\t7. otherwise press ENTER to continue...\n"); + + getchar(); //wait for keyboard input + + SecPrint(""); //now you can single step the entire boot/emulati= on process, good luck... + } + } + // // Determine the first thread available to this process. // From: Ni, Ray Sent: Thursday, November 14, 2019 07:57 AM To: Kilian Kegel; devel@edk2.groups.io; Gao, Liming Cc: Richardson, Brian; Kinney, Michael = D Subject: RE: [edk2-devel] [[PATCH 1/1]] EmulatorPkg using CpuBreakPoint Kilian, Thank you very much. Comments below. From: Kilian Kegel Sent: Thursday, November 14, 2019 1:24 PM To: Ni, Ray ; devel@edk2.groups.io; Gao, Liming Cc: Richardson, Brian ; Kinney, Michael D Subject: RE: [edk2-devel] [[PATCH 1/1]] EmulatorPkg using CpuBreakPoint I have no preference at all here. We can also consider to use a stricmp() = to be case-in-sensitive=85 [Ray] I am ok to either case sensitive or insensitive. Thanks, Kilian diff --git a/EmulatorPkg/Win/Host/WinHost.c b/EmulatorPkg/Win/Host/WinHost= .c index 62a89f7617..0eeb5979ff 100644 --- a/EmulatorPkg/Win/Host/WinHost.c +++ b/EmulatorPkg/Win/Host/WinHost.c @@ -394,6 +394,7 @@ Returns: UINTN ProcessAffinityMask; UINTN SystemAffinityMask; INT32 LowBit; + INT32 i; [Ray] 1. Can you please rename it to =93Index=94 to align the coding style= ? // // Enable the privilege so that RTC driver can successfully run SetTime= () @@ -410,6 +411,26 @@ Returns: SecPrint ("\n\rEDK II WIN Host Emulation Environment from http://www.ti= anocore.org/edk2/\n\r"); + SecPrint ("############################################################= ##########################################\n"); + SecPrint ("add \"/debug\" command line switch, to connect to the debugg= er at the very beginning of POST emulation\n"); + SecPrint ("############################################################= ##########################################\n"); + if (Argc > 1) { [Ray] 2. Can you remove the if check? It=92s unnecessary because of below = for-loop. + for (i =3D 1; i < Argc; i++) { + if (0 =3D=3D strcmp("/debug", Argv[i])) { + SecPrint("\t1. start your debug engine\n"); + SecPrint("\t2. attach to process WinHost.exe\n"); [Ray] 3. I don=92t think it=92s proper to hardcode line number in code bec= ause that will cause this debug message is changed in future. Can you remove the line number? + 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 = the application\n"); + SecPrint("\t7. otherwise press enter to continue...\n"); + + getchar(); //wait for keyboard input + + SecPrint("");//now you can single step the entire boot/emulatio= n process, good luck... + } + } + } + // // Determine the first thread available to this process. // From: Ni, Ray Sent: Wednesday, November 13, 2019 03:27 AM To: devel@edk2.groups.io; Gao, Liming; KILIAN_KEGEL@OUTLOOK.COM Cc: Richardson, Brian; Kinney, Michael = D Subject: RE: [edk2-devel] [[PATCH 1/1]] EmulatorPkg using CpuBreakPoint Kilian, Thank you very much for enabling the better VS debugging experience. Minor comments below. From: devel@edk2.groups.io > On Behalf Of Liming Gao Sent: Wednesday, November 13, 2019 9:07 AM To: devel@edk2.groups.io; KILIAN_KEGEL@OUTLOO= K.COM Cc: Richardson, Brian >; Kinney, Michael D >; Gao, Liming > Subject: Re: [edk2-devel] [[PATCH 1/1]] EmulatorPkg using CpuBreakPoint Kilian: Can you create the patch with the commit message? For the patch, I add my comments. From: devel@edk2.groups.io [mailto:devel@edk2= .groups.io] On Behalf Of Kilian Kegel Sent: Wednesday, November 06, 2019 1:36 AM To: Gao, Liming > Cc: devel@edk2.groups.io; Richardson, Brian <= brian.richardson@intel.com>; Kinney, Mic= hael D > Subject: [edk2-devel] [[PATCH 1/1]] EmulatorPkg using CpuBreakPoint 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.ti= anocore.org/edk2/\n\r"); - + + if (1) { Please use TRUE instead of 1 [Ray] 1. Can you remove =93if(1)=94? + int i; Please define it in the begin of the function, and use edk2 data type and = coding style, such as UINTN Index. + SecPrint ("##########################################################= ############################################\n"); + SecPrint ("add \"/debug\" command line switch, to connect to the debu= gger 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])) { How about use strncmp? [Ray] 2. strncmp assumes user may input =93/debugxxxxx=94. Is that a valid= assumption? I thought we only accept =93/debug=94 the whole word as input = parameter to trigger debugging. Thanks Liming + //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 debugg= er\n\t3. and press ENTER in this command box\nOR\n"); [Ray] 3. I prefer to break the long string to multiple lines of SecPrint()= call as what the code does in below. + 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 = the application\n"); + SecPrint("\t7. otherwise press enter to continue...\n"); + + getchar(); //wait for keyboard input + + SecPrint("");//now you can single step the entire boot/emulatio= n 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 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_VI1PR0502MB396822D564BDF2ED5A713FC2EB700VI1PR0502MB3968_ Content-Type: text/html; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable

Ray,

 

thank you for your patience.

 

Kilian

 

diff --git a/EmulatorPkg/Win/Host/WinHost.c b/Emula= torPkg/Win/Host/WinHost.c

index 62a89f7617..b47a1fa8dd 100644

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

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

@@ -394,6 +394,7 @@ Returns:

   UINTN     &nb= sp;           ProcessAffi= nityMask;

   UINTN     &nb= sp;           SystemAffin= ityMask;

   INT32     &nb= sp;           LowBit;

+  INT32     &nbs= p;           index;

   //

   // Enable the privilege so that RTC dr= iver can successfully run SetTime()

@@ -410,6 +411,24 @@ Returns:

   SecPrint ("\n\rEDK II WIN Ho= st Emulation Environment from http://www.tianocore.org/edk2/\n\r");

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

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

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

+  for (index =3D 1; index < Argc; inde= x++) {

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

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

+        Sec= Print("\t2. attach to process WinHost.exe\n");

+        Sec= Print("\t4. set software breakpoints as needed in your debug session\n= ");

+        Sec= Print("\t5. and press ENTER in the WinHost command box\n");

+        Sec= Print("\t6. go back to the debug engine and RUN/SINGLE STEP the applic= ation\n");

+        Sec= Print("\t7. otherwise press ENTER to continue...\n");

+

+        get= char();      //wait for keyboard input

+

+        Sec= Print("");   //now you can single step the entire boot/= emulation process, good luck...

+    }

+  }

+

   //

   // Determine the first thread availabl= e to this process.

   //

From: Ni, Ray
Sent: Thursday, November 14, 2019 07:57 AM
To: Kilian Kegel; <= a href=3D"mailto:devel@edk2.groups.io"> devel@edk2.groups.io; Gao, Lim= ing
Cc: Richardson, Brian= ; Kinney, Michael D
Subject: RE: [edk2-devel] [[PATCH 1/1]] EmulatorPkg using CpuBreakP= oint

 

Kilian,

Thank you very much. Comments below.

 

 

From: Kilian Kegel <kilian_kegel@outlook.= com>
Sent: Thursday, November 14, 2019 1:24 PM
To: Ni, Ray <ray.ni@intel.com>; devel@edk2.groups.io; Gao, Li= ming <liming.gao@intel.com>
Cc: Richardson, Brian <brian.richardson@intel.com>; Kinney, M= ichael D <michael.d.kinney@intel.com>
Subject: RE: [edk2-devel] [[PATCH 1/1]] EmulatorPkg using CpuBreakP= oint

 

I have no preference at all here. We can also consider to use a stricmp()= to be case-in-sensitive=85

[Ray] I am ok to either case sensitive or insensiti= ve.

 

Thanks,

Kilian

 

diff --git a/EmulatorPkg/Win/Host/WinHost.c b/Emula= torPkg/Win/Host/WinHost.c

index 62a89f7617..0eeb5979ff 100644

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

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

@@ -394,6 +394,7 @@ Returns:

   UINTN     &nb= sp;           ProcessAffi= nityMask;

   UINTN     &nb= sp;           SystemAffin= ityMask;

   INT32     &nb= sp;           LowBit;

+  INT32     &nbs= p;           i;

[Ray] 1. Can you please rename it to =93Index=94 to= align the coding style?

 

   //

   // Enable the privilege so that RTC dr= iver can successfully run SetTime()

@@ -410,6 +411,26 @@ Returns:

   SecPrint ("\n\rEDK II WIN Ho= st Emulation Environment from http://www.tianocore.org/edk= 2/\n\r");

+  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) {

[Ray] 2. Can you remove the if check? It=92s unnece= ssary because of below for-loop.

 

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

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

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

+       &nbs= p;  SecPrint("\t2. attach to process WinHost.exe\n");

 

[Ray] 3. I don=92t think it=92s proper to hardcode = line number in code because that will cause this debug message is changed i= n future.

Can you remove the line number?

 

+        &nb= sp; SecPrint("\t4. SET A SOFTWARE BREAKPOINT (F9) in line 431\n&q= uot;);

+       &nbs= p;  SecPrint("\t5. and press ENTER in the WinHost command box\n&q= uot;);

+       &nbs= p;  SecPrint("\t6. go back to the debug engine and RUN/SINGLE STE= P the application\n");

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

+

+       &nbs= p;  getchar();    //wait for keyboard input<= /p>

+

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

+      }

+    }

+  }

+

   //

   // Determine the first thread availabl= e to this process.

   //

From: Ni= , Ray
Sent: Wednesday, November 13, 2019 03:27 AM
To: devel@edk2.groups.io; Gao, Liming; KILIAN_KEGEL@= OUTLOOK.COM
Cc: Richardson, Brian= ; Kinney, Michael D
Subject: RE: [edk2-devel] [[PATCH 1/1]] EmulatorPkg using CpuBreakP= oint

 

Kilian,

Thank you very much for enabling the better VS debu= gging experience.

 

Minor comments below.

 

From: devel@edk2.groups.io <deve= l@edk2.groups.io> On Behalf Of Liming Gao
Sent: Wednesday, November 13, 2019 9:07 AM
To: devel@edk2.groups.io; KILIAN_KEGEL@OUTLOOK.COM
Cc: Richardson, Brian <brian.richardson@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Gao, = Liming <liming.gao@intel.com= >
Subject: Re: [edk2-devel] [[PATCH 1/1]] EmulatorPkg using CpuBreakP= oint

 

Kilian:

  Can you create= the patch with the commit message?

 

  For the patch,= I add my comments.

 

 

From: devel@edk2.groups.io [mailto:= devel@edk2.groups.io] On Behalf Of Kilian Kegel
Sent: Wednesday, November 06, 2019 1:36 AM
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] [[PATCH 1/1]] EmulatorPkg using CpuBreakPoint=

 

Hi Liming,

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

Regards,

Kilian

 

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

 

diff --git a/EmulatorPkg/Win/Host/WinHost.c b/Emula= torPkg/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 *) PcdG= etPtr (PcdEmuFirmwareVolume);

   SecPrint ("\n\rEDK II WIN Host Em= ulation Environment from http://www.tianocore.org/edk= 2/\n\r");

-

+  if (1) {

Please use TRUE inste= ad of 1

[Ray] 1. Can you remove =93if(1)=94?

 

+    int i;

Please define it in t= he begin of the function, and use edk2 data type and coding style, such as = UINTN Index.

 

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

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

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

+    if (Argc > 1) {

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

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

How about use strncmp= ?

[Ray] 2. strncmp assumes user may input =93/debugxx= xxx=94. Is that a valid assumption? I thought we only accept =93/debug=94 t= he whole word as input parameter to trigger debugging.

 

Thanks

Liming

+       &nbs= p;  //SecPrint("IF YOU WANT TO DEBUG from the very beginning of t= he EMULATION:\n\t1. start the TASKMGR\n\t2. connect WinHost.exe to the debu= gger\n\t3. and press ENTER in this command box\nOR\n");

[Ray] 3. I prefer to break the long string to multi= ple lines of SecPrint() call as what the code does in below.

 

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

+       &nbs= p;  SecPrint("\t2. attache to process WinHost.exe\n");<= /o:p>

+       &nbs= p;  SecPrint("\t4. SET A SOFTWARE BREAKPOINT (F9) in line 431\n&q= uot;);

+       &nbs= p;  SecPrint("\t5. and press ENTER in the WinHost command box\n&q= uot;);

+       &nbs= p;  SecPrint("\t6. go back to the debug engine and RUN/SINGLE STE= P the application\n");

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

+

+       &nbs= p;  getchar();    //wait for keyboard input<= /p>

+

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

+        }

+      }

+    }

+  }

   //

   // Determine the first thread availabl= e to this process.

   //

 

From: Kilian Kegel <kilian_kegel@outlook.com>
Sent: Monday, October 28, 2019 2:01:23 PM
To: liming.gao@intel.com <liming.gao@intel.com><= br> Cc: devel@edk2.groups.io <devel@edk2.groups.io>;= Richardson, Brian <brian.= 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 Windows 10 versions, whe= n 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 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;

 

        SecP= rint ("###############################################################= #######################################\n");

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

        SecP= rint ("###############################################################= #######################################\n");

 

        if(A= rgc > 1){

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

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

        = ;            &n= bsp;   //SecPrint("IF YOU WANT TO DEBUG from the very beginn= ing 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");

        = ;            &n= bsp;   SecPrint("\t1. start Visual Studio\n");

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

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

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

        = ;            &n= bsp;   SecPrint("\t5. and press ENTER in this command box\n&= quot;);

        = ;            &n= bsp;   SecPrint("\t6. go back to Visual Studio an RUN/SINGLE= STEP the application\n");

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

        = ;            &n= bsp;   getchar();

        = ;            &n= bsp;   //

        = ;            &n= bsp;   // 1. SET A SOFTWARE BREAKPOINT TO THE NEXT LINE of code b= elow -->> SecPrint("");

        = ;            &n= bsp;   // 2. switch to the command box and press ENTER

        = ;            &n= bsp;   // 3. start single stepping the entire boot/emulation proc= ess, good luck...

        = ;            &n= bsp;   //

        = ;            &n= bsp;   SecPrint("");//now you can single step the entir= e boot/emulation process, good luck...

        = ;           }

        = ;    }

        }

    }

 

 

--_000_VI1PR0502MB396822D564BDF2ED5A713FC2EB700VI1PR0502MB3968_-- --_005_VI1PR0502MB396822D564BDF2ED5A713FC2EB700VI1PR0502MB3968_ Content-Type: image/png; name="image001.png" Content-Description: image001.png Content-Disposition: inline; filename="image001.png"; size=144; creation-date="Thu, 14 Nov 2019 06:57:12 GMT"; modification-date="Thu, 14 Nov 2019 06:57:12 GMT" Content-ID: Content-Transfer-Encoding: base64 iVBORw0KGgoAAAANSUhEUgAAArYAAAACCAYAAACtx5+mAAAAAXNSR0IArs4c6QAAAARnQU1BAACx jwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAlSURBVFhH7cMBDQAABAAw/UtJIIEw5GD/9gAA gBeyelRV9faeBRsQNwwY9nKzAAAAAElFTkSuQmCC --_005_VI1PR0502MB396822D564BDF2ED5A713FC2EB700VI1PR0502MB3968_ Content-Type: image/png; name="image002.png" Content-Description: image002.png Content-Disposition: inline; filename="image002.png"; size=144; creation-date="Thu, 14 Nov 2019 06:57:12 GMT"; modification-date="Thu, 14 Nov 2019 06:57:12 GMT" Content-ID: Content-Transfer-Encoding: base64 iVBORw0KGgoAAAANSUhEUgAAAsQAAAACCAYAAABfe8oDAAAAAXNSR0IArs4c6QAAAARnQU1BAACx jwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAlSURBVFhH7cMBDQAACAMg+5cygQkeRoMIGwUA AK/1ZFVV9efsAW0/ZqCCeHKlAAAAAElFTkSuQmCC --_005_VI1PR0502MB396822D564BDF2ED5A713FC2EB700VI1PR0502MB3968_--